package asteroids.components;

import asteroids.scenes.Level;

import com.uqbar.vainilla.DeltaState;
import com.uqbar.vainilla.GameComponent;

public abstract class AbstractAsteroidsGameComponent extends GameComponent<Level> {

	protected double direction = 0;
	protected double speed     = 0;
	protected double versorI   = Math.sin(this.getDirection());
	protected double versorJ   = Math.cos(this.getDirection());

	protected static int GAME_HEIGHT;
	protected static int GAME_WIDTH;
	
	protected static final int SHIP_AREA = 200;

	@Override
	public void update(DeltaState deltaState) {
		
		if (this.getY() > GAME_HEIGHT)
			this.setY(-this.getAppearance().getHeight());
		
		if (this.getX() > GAME_WIDTH)
			this.setX(-this.getAppearance().getWidth());
		
		if (this.getY() + this.getAppearance().getHeight() < 0)
			this.setY(GAME_HEIGHT);
		
		if (this.getX() + this.getAppearance().getWidth() < 0)
			this.setX(GAME_WIDTH);
		
		super.update(deltaState);
	}
	
	


	public double getDirection() {
		return direction;
	}

	public void setDirection(double direction) {
		this.direction = direction;
	}
	
	public double getVersorI() {
		return versorI;
	}

	public void setVersorI(double vectorI) {
		this.versorI = vectorI;
	}

	public double getVersorJ() {
		return versorJ;
	}

	public void setVersorJ(double vectorJ) {
		this.versorJ = vectorJ;
	}
	
	public double getSpeed() {
		return speed;
	}

	public void setSpeed(double speed) {
		this.speed = speed;
	}
}
